package com.huangliusong.demo2;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class SpringDemo2 {

    public void test(){
        //创建工厂
        ApplicationContext applicationContext=new ClassPathXmlApplicationContext("applicationContext.xml");
        //通过工厂获取实例
        Bean1 bean1=(Bean1)applicationContext.getBean("bean2");

    }

    public void test2(){
        //创建工厂
        ApplicationContext applicationContext=new ClassPathXmlApplicationContext("applicationContext.xml");
        //通过工厂获取实例
        Bean2 bean1=(Bean2)applicationContext.getBean("bean2");

    }


    @Test
    public void test3(){
        //创建工厂
        ApplicationContext applicationContext=new ClassPathXmlApplicationContext("applicationContext.xml");
        //通过工厂获取实例
        Bean3 bean3=(Bean3)applicationContext.getBean("bean3");

    }
}
